package com.yanq.liancar.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.MailAddressBean;

import java.util.List;

public class MailAddressAdapter extends BaseQuickAdapter<MailAddressBean.DataBean, BaseViewHolder> {
    public MailAddressAdapter(int layoutResId, @Nullable List<MailAddressBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MailAddressBean.DataBean item) {
        helper.setText(R.id.tv_name, item.getGainpeo())
                .setText(R.id.tv_phoneNum, item.getCont_phone())
                .setText(R.id.tv_address, item.getAddr_detail())
                .addOnClickListener(R.id.img_modify)
                .addOnClickListener(R.id.img_delete)
                .addOnClickListener(R.id.ll_default);

        ImageView imageView = helper.getView(R.id.img_status);
        TextView textView=helper.getView(R.id.tv_status);
        if (1==item.getDefault_mark()) {
            imageView.setImageResource(R.mipmap.xuanzhong);
            textView.setTextColor(mContext.getResources().getColor(R.color.main_color));
        } else {
            textView.setTextColor(mContext.getResources().getColor(R.color.gray));
            imageView.setImageResource(R.mipmap.weixuanzhong);
        }
    }
}
